<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>


		<title>My JSP 'room.jsp' starting page</title>
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/easyui/1.3.4/themes/default/easyui.css" />
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/wu.css" />
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/icon.css" />
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript">
		
			$(function() {
		$("form").submit(function(){
			var name=$("input[name='name']").val();
			var descroom=$("input[name='descroom']").val();
			if(name==""||name==null ){
				alert('会议室名不能为空');
				return false;
				}else if(name.length>15){
				alert('不能超出最大范围');
				return false;
				}
				
			if(descroom==""||descroom==null){
				alert('请描述会议室');
				return false;
			}else if(descroom.length>50){
				alert('不能超出最大范围');
				return false;
				}
				return true;	
		});
		});
		
		
	$(function() {
		$(function() {
			$("#yuding").click(function(){
				location.href = "room.jsp";
			});
			$("#chaxun").click(function(){
				$("#xun").css("display", "block");
				$("#xunyin").css("display", "none");
			});
			$("#btnx").click(function(){
				var endb = $("#endb").datetimebox('getValue');
				var startb = $("#startb").datetimebox('getValue');	
				var didb = $("#typeb").combobox('getValue');
				var yuname = $("#yuname").val();
				var roomname = $("#roomname").val();
				$("#bgm").datagrid( {
				url : '${pageContext.request.contextPath}/roomorder?op=show',
				queryParams: {
					start: startb,
					end: endb,
					dicid: didb,
					username:yuname,
					roomname:roomname
				},
				
				columns : [ [ 
					{field:'id',title:'选择',width:30,checkbox:true}, 
					{field:'roomkind',title:'会议室名称',width:50,
						formatter: function(value,row,index){
							return value.name;
						}
					},
					{field:'starttime',title:'会议室起始时间',width:100,
						formatter: function(value,row,index){
							return value.substring(0,19);
						}
					},
					{field:'endtime',title:'会议室结束时间',width:100,
						formatter: function(value,row,index){
							return value.substring(0,19);
						}
					},
					{field:'dictionary',title:'会议室用途',width:100,
						formatter: function(value,row,index){
							return value.dictname;
						}
					},
					{field:'user',title:'预定人',width:100,
						formatter: function(value,row,index){
							return value.realname;
						}
					} 
					
        			
				] ],
				striped : true,
				fitColumns : true,
				loadMsg : '请等待...',
				singleSelect : true,
				toolbar : [{
					iconCls : 'icon-remove',
					handler : function(){
						var obj = $('#bgm').datagrid("getSelected");
								location.href = "${pageContext.request.contextPath}/roomorder?op=delete&id="
										+ obj.id;
						}
					}]

				});	
			});
			
			$("#guanli").click(function(){
				var role = ${sys_user.role.id}
				if(role==4||role==1){
				$("#xunyin").css("display", "block");	
				$("#bcc").css("display", "none");
				$("#xun").css("display", "none");
				$('#tab').datagrid({
							url : '${pageContext.request.contextPath}/roomKind?op=show',
							columns : [ [ 
							{
								field : 'id',
								title : '编号',
								width : 110
							}, {
								field : 'name',
								title : '会议室名称',
								width : 190
							}, {
								field : 'descroom',
								title : '会议室描述',
								width : 190
							}

						] ],
						striped : true,
						fit : true,
						fitColumns : true,
						loadMsg : '请等待...',
						toolbar : [{
							iconCls : 'icon-add',
							handler : function() {
								$("#win").css("display", "block");
								
								$("#win").window({
													width : 600,
													height : 400,
													modal : true,
													title : '新增会议室',
													iconCls : 'icon-add'
												});
											}
										},'-',{
												iconCls : 'icon-remove',
												handler : function() {
													var obj = $('#tab').datagrid("getSelected");
													location.href = "${pageContext.request.contextPath}/roomKind?op=delete&id="
															+ obj.id;
												}
							} ]
						});
						}else{
							alert("对不起您不是人事专员或系统管理员");
						}
					});
		});

	});

	$(function() {
		$("#typeb").combobox( {
			url : '${pageContext.request.contextPath}/dictionary?op=dictchild&secid=8',
			valueField : 'id',
			textField : 'dictname',
			panelHeight : 'auto'
		});
		$("#type").combobox( {
			url : '${pageContext.request.contextPath}/dictionary?op=dictchild&secid=8',
			valueField : 'id',
			textField : 'dictname',
			panelHeight : 'auto'
		});

		$("#btnb").click(function() {
			var obj = $('#dg').datagrid("getSelected");
			var end = $("#end").datetimebox('getValue');
			var start = $("#start").datetimebox('getValue');
			var userid = $("#userid").val();
			var did = $("#type").combobox('getValue');
			alert("申请成功");
			location.href = "${pageContext.request.contextPath}/roomorder?op=save&rid="+obj.id+"&userid="+userid+"&did="+did+"&starttime="+start+"&endtime="+end;
		})

		$("#btn").click(function() {
			$("#wb").css("display", "block");
			var end = $("#end").datetimebox('getValue');
			var start = $("#start").datetimebox('getValue');
			$("#dg").datagrid( {
				url : '${pageContext.request.contextPath}/roomKind?op=showOk&start=' + start + '&end=' + end,
				columns : [ [ {
					field : 'id',
					title : '编号',
					width : 110,
					checkbox : true
				}, {
					field : 'name',
					title : '会议室名称',
					width : 190
				}, {
					field : 'descroom',
					title : '会议室描述',
					width : 190
				}

				] ],
				striped : true,
				fitColumns : true,
				loadMsg : '请等待...',
				singleSelect : true

			});
		})
	})
</script>

	</head>

	<body class="easyui-layout">
		<div data-options="region:'west',title:'会议室管理',split:true"
			style="width: 200px;">
			<ul>
				<li style="list-style: none; font-size: 20px;margin-top: 20px">
					<a href="javascript:void();" id="yuding">会议室预订</a>
				</li>
				<li style="list-style: none; font-size: 20px;margin-top: 20px">
					<a href="javascript:void();" id="chaxun">会议室查询</a>
				</li>
				<li style="list-style: none; font-size: 20px;margin-top: 20px">
					<a href="javascript:void();" id="guanli">会议室管理</a>
				</li>
			</ul>

		</div>

		<div data-options="region:'center'">
			<div id="xun" style="width: 800px; height: 400px; display: none;">
				<div
					style="width: 800px; height: 100px; border-bottom: 2px solid black;">
					<div>
						<div style="margin-left: 45px">
							<input class="easyui-datetimebox" name="startb"
								data-options="showSeconds:true" style="width: 150px" id="startb">

							<input class="easyui-datetimebox" name="endb"
								data-options="showSeconds:true" style="width: 150px" id="endb">
						</div>
						<br>
						预定人：
						<input type="text" name="yudingname" id="yuname">
						会议室名称：
						<input type="text" name="roomname" id="roomname">
						会议室类型：
						<input type="text" id="typeb">

						<br>
						<a id="btnx" href="javascript:void(0);" class="easyui-linkbutton">查询</a>
					</div>
					<div>
						<table id="bgm"></table>
					</div>

				</div>


			</div>
			<div id="xunyin">
				<table id="tab"></table>
				<div id="win" style="display: none;">
					<form action="roomKind.html?op=save" method="post">
						会议室名称：
						<input type="text" name="name">
						<br>
						会议室描述：
						<input type="text" name="descroom">
						<br>
						<input type="submit" value="保存">
					</form>
				</div>
				<div
					style="margin-left: 60px; margin-top: 30px; height: 50px; width: 800px; border-bottom: 2px solid black;" id="bcc">

					<input type="hidden" id="userid" value="${sys_user.id }">


					<input class="easyui-datetimebox" name="start"
						data-options="showSeconds:true" style="width: 150px" id="start">

					<input class="easyui-datetimebox" name="end"
						data-options="showSeconds:true" style="width: 150px" id="end">
					<a id="btn" href="javascript:void(0);" class="easyui-linkbutton">查询</a>
				</div>
				<div id="ddd"
					style="margin-left: 60px; margin-top: 30px; height: 300px; width: 800px;">
					<table id="dg"></table>
					<div id="wb" style="margin-top: 10px; display: none;">
						<div style="float: left;">
							申请人：${sys_user.realname }
						</div>
						<div style="float: left; margin-left: 300px">
							使用类型：
							<input type="text" id="type">
						</div>
						<div style="float: left; margin-left: 40px">
							<a id="btnb" href="javascript:void(0);" class="easyui-linkbutton">申请</a>
						</div>
					</div>
				</div>
			</div>

		</div>
	</body>
</html>
